package com.guigu.mq.callback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @ClassName:ReturnCallback
 * @Description://TODO
 * @Author:taoLong
 * @Date:2021/11/4:14:42 星期四
 * @email:2391611102@qq.com or 2391611102qq@gmail.com
 */
@Slf4j
@Component
public class ReturnCallback implements RabbitTemplate.ReturnCallback {
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.error("路由失败!,消息被退回!,消息体为:{},replyCode为:{},replyTest为{},交换机为:{},路由路径为:{}",
                new String(message.getBody(), StandardCharsets.UTF_8), replyCode, replyText, exchange, routingKey);
    }
}
